<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>CDEFs</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="The Cacti Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="RRDTool Specific Features"
HREF="rrdtool_features.html"><LINK
REL="PREVIOUS"
TITLE="RRDTool Specific Features"
HREF="rrdtool_features.html"><LINK
REL="NEXT"
TITLE="Command Line Scripts"
HREF="scripts.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="manual.css"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The Cacti Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="rrdtool_features.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 19. RRDTool Specific Features</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="scripts.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="CDEFS"
>CDEFs</A
></H1
><P
>				CDEFs allow you to apply mathematical functions to graph data to alter output. The concept of a
				CDEF comes straight from <SPAN
CLASS="APPLICATION"
>RRDTool</SPAN
>, and are written in reverse polish notation (RPN). For more
				information regarding the syntax of CDEFs, check out the <A
HREF="http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdgraph_data.en.html"
TARGET="_top"
>CDEF tutorial</A
>.
			</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="ADD_NEW_CDEF"
>Creating a CDEF</A
></H2
><P
>					To create a new CDEF in Cacti, select the <SPAN
CLASS="GUILABEL"
>Graph Management</SPAN
> option under
					the <SPAN
CLASS="GUILABEL"
>Management</SPAN
> heading, and select <SPAN
CLASS="GUILABEL"
>CDEFs</SPAN
>. Once at
					this screen, click <SPAN
CLASS="GUILABEL"
>Add</SPAN
> to the right. You will be prompted for a CDEF
					name, for which you can type anything used to describe your CDEF. Click the <SPAN
CLASS="GUILABEL"
>Create</SPAN
>
					button so you are redirected back to the edit page, now with an empty <SPAN
CLASS="GUILABEL"
>CDEF Items</SPAN
>
					box. Construct your CDEF by adding an item for each element in the CDEF string, common types such as
					operators and functions are enumerated for your convenience. Below is a basic description of each
					CDEF item type.
				</P
><DIV
CLASS="TABLE"
><A
NAME="AEN2832"
></A
><P
><B
>Table 19-1. CDEF Item Types</B
></P
><TABLE
BORDER="1"
FRAME="border"
RULES="all"
CLASS="CALSTABLE"
><COL
WIDTH="1*"><COL
WIDTH="3*"><THEAD
><TR
><TH
ALIGN="CENTER"
>Type</TH
><TH
ALIGN="CENTER"
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>Function</TD
><TD
>You can choose a CDEF function to use as the item. The <A
HREF="http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdgraph.en.html"
TARGET="_top"
>RRDTool graph manual</A
> describes the purpose of each CDEF function.</TD
></TR
><TR
><TD
>Operator</TD
><TD
>Just your standard math operators, including modulo (%).</TD
></TR
><TR
><TD
>Special Data Source</TD
><TD
>A special data source is basically a flag to tell Cacti to do some special processing when it encounters this CDEF item. The "Current Graph Item Data Source" type basically inserts the name of the data source that is referenced by the graph item that references to this CDEF. Both of the "All Data Sources" types insert a summation of all data sources used on a graph.</TD
></TR
><TR
><TD
>Another CDEF</TD
><TD
>You can recursively use another CDEF within this CDEF.</TD
></TR
><TR
><TD
>Custom String</TD
><TD
>Sometimes it's just easier to type out the literal CDEF string manually. When referencing to data sources on the graph, remember that Cacti names them 'a', 'b', 'c', '...', starting with the first data source on the graph.</TD
></TR
></TBODY
></TABLE
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="CDEF_SPECIAL_DATA_SOURCE"
>Special Data Source</A
></H2
><P
>The <SPAN
CLASS="GUILABEL"
>Special Data Souce</SPAN
> selection introduces some variables not known
				to plain vanilla rrdtool. Let's spend some few words of them to unleash their power.</P
><DIV
CLASS="TABLE"
><A
NAME="AEN2862"
></A
><P
><B
>Table 19-2. CDEF Special Data Source</B
></P
><TABLE
BORDER="1"
FRAME="border"
RULES="all"
CLASS="CALSTABLE"
><COL
WIDTH="1*"><COL
WIDTH="3*"><THEAD
><TR
><TH
ALIGN="CENTER"
>Special Data Source</TH
><TH
ALIGN="CENTER"
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>Current Graph Item Data Source</TD
><TD
>Will be replaced by the DEF name of the rrdtool data source referred by the graph item this CDEF is associated to.</TD
></TR
><TR
><TD
>All Data Sources (Don't Include Duplicates)</TD
><TD
>Will add up all data sources of the whole graph to form a total. A data source that appears more than once will be counted only once. Data sources that differ by consolidation functions only are NOT counted as different data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted only once). It is NOT required to associate the graph item to any data source!</TD
></TR
><TR
><TD
>All Data Sources (Include Duplicates)</TD
><TD
>Will add up all data sources of the whole graph to form a total. A data source that appears more than once will be counted for each time of it's appearance. Data sources that differ by consolidation functions only are NOT counted as different data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted only once). It is NOT required to associate the graph item to any data source!</TD
></TR
><TR
><TD
>Similar Data Sources (Don't Include Duplicates)</TD
><TD
>It is REQUIRED to associate the graph item to the data source that shall be totalled! Let's assume the data source is named "traffic_in". Then, cacti will add up all data sources "traffic_in" of the whole graph to form a data source specific total (e.g. Total traffic In). Data sources with different consolidation functions are counted as same data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted once)</TD
></TR
><TR
><TD
>Similar Data Sources (Include Duplicates)</TD
><TD
>It is REQUIRED to associate the graph item to the data source that shall be totalled! If a data source appears multiple times, it will be added this many times.</TD
></TR
><TR
><TD
>Current Data Source Item: Minimum Value</TD
><TD
>Taken from the Data Template - Data Source Item related to this graph item: fetches the minimum value defined for the given data template. Caution: This is NOT the smallest entry of the given data source!</TD
></TR
><TR
><TD
>Current Data Source Item: Maximum Value</TD
><TD
>Taken from the Data Template - Data Source Item related to this graph item: fetches the maximum value defined for the given data template. Caution: This is NOT the highest entry of the given data source!</TD
></TR
><TR
><TD
>Graph: Lower Limit</TD
><TD
>Taken from the Graph Template: fetches the Lower Limit defined to the Graph Template. This is independant of all --alt-autoscaling options. It is NOT the dynamically determined lower boundary of the graph!</TD
></TR
><TR
><TD
>Graph: Upper Limit</TD
><TD
>Taken from the Graph Template: fetches the Upper Limit defined to the Graph Template. This is independant of all --alt-autoscaling options. It is NOT the dynamically determined upper boundary of the graph!</TD
></TR
><TR
><TD
>Count of All Data Sources (Don't Include Duplicates)</TD
><TD
>Will count the number of all data sources of the whole graph. A data source that appears more than once will be counted only once. Data sources that differ by consolidation functions only are NOT counted as different data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted only once). It is NOT required to associate the graph item to any data source!</TD
></TR
><TR
><TD
>Count of All Data Sources (Include Duplicates)</TD
><TD
>Will count the number of all data sources of the whole graph. A data source that appears more than once will be counted for each time of it's appearance. Data sources that differ by consolidation functions only are NOT counted as different data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted only once). It is NOT required to associate the graph item to any data source!</TD
></TR
><TR
><TD
>Count of Similar Data Sources (Don't Include Duplicates)</TD
><TD
>It is REQUIRED to associate the graph item to the data source that shall be counted! Let's assume the data source is named "traffic_in". Then, cacti will count all data sources "traffic_in" of the whole graph. Data sources with different consolidation functions are counted as same data sources (e.g. traffic_in:AVERAGE and traffic_in:MAX are counted once)</TD
></TR
><TR
><TD
>Count of Similar Data Sources (Include Duplicates)</TD
><TD
>It is REQUIRED to associate the graph item to the data source that shall be counted! If a data source appears multiple times, it will be counted this many times.</TD
></TR
></TBODY
></TABLE
></DIV
><P
>While the <CODE
CLASS="PARAMETER"
>All Data Sources/Similar Data Sources</CODE
> pseudo CDEF variables
				perform <B
CLASS="EMPHASIS"
>totaling</B
>, the <CODE
CLASS="PARAMETER"
>Count All Data Sources/Count Similar Data Sources</CODE
>
				pseudo CDEF Variables simply <B
CLASS="EMPHASIS"
>count</B
> the occurences of the related data sources.
				Thus, it is easy to compute e.g. an average of all similar data sources by creating the CDEF
				</P
><PRE
CLASS="SCREEN"
>CDEF=SIMILAR_DATA_SOURCES_NODUPS,COUNT_SIMILAR_DS_NODUPS,/</PRE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="CDEF_SPECIAL_DATA_SOURCE_EXAMPLES"
>Using Special Data Source</A
></H2
><P
>Let's have some examples:</P
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN2920"
></A
><P
><B
>Example 19-1. Sum up all Data Sources Omitting Duplicates</B
></P
><P
>This is the list of graph items defined. Please note,
					that Item#17-20 are duplicates of Item#1-4. Even if it usually does not make sense, for this
					discussion it is very valuable. Item#21-24 are related to a
					<B
CLASS="EMPHASIS"
>cdef=ALL_DATA_SOURCES_NODUPS</B
></P
><PRE
CLASS="SCREEN"
>Graph Item  Data Source                         Graph Item Type  CF Type
Item # 1    (traffic_in): 1. Target Traffic In 	          LINE1  AVERAGE
Item # 2    (traffic_in): Current:                       GPRINT     LAST
Item # 3    (traffic_in): Average:                       GPRINT  AVERAGE
Item # 4    (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 5    (traffic_in): 2. Target Traffic In            LINE1  AVERAGE
Item # 6    (traffic_in): Current:                       GPRINT     LAST
Item # 7    (traffic_in): Average:                       GPRINT  AVERAGE
Item # 8    (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 9    (traffic_out): 1. Target Traffic Out          LINE1  AVERAGE
Item # 10   (traffic_out): Current:                      GPRINT     LAST
Item # 11   (traffic_out): Average:                      GPRINT  AVERAGE
Item # 12   (traffic_out): Maximum:[HR]                  GPRINT      MAX
Item # 13   (traffic_out): 2. Target Traffic Out          LINE1  AVERAGE
Item # 14   (traffic_out): Current:                      GPRINT     LAST
Item # 15   (traffic_out): Average:                      GPRINT  AVERAGE
Item # 16   (traffic_out): Maximum:[HR]                  GPRINT      MAX
Item # 17   (traffic_in): 1. Target Again Traffic In      LINE1  AVERAGE
Item # 18   (traffic_in): Current:                       GPRINT     LAST
Item # 19   (traffic_in): Average:                       GPRINT  AVERAGE
Item # 20   (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 21   (No Task): AllDsNoDups                        LINE1  AVERAGE
Item # 22   (No Task): Current:                          GPRINT     LAST
Item # 23   (No Task): Average:                          GPRINT  AVERAGE
Item # 24   (No Task): Maximum:[HR]                      GPRINT      MAX</PRE
><P
>And this is the rrd graph statement:</P
><PRE
CLASS="SCREEN"
>/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Traffic AllDsNoDups" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:AVERAGE \
DEF:b="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:MAX \
DEF:c="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:AVERAGE \
DEF:d="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:MAX \
DEF:e="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:AVERAGE \
DEF:f="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:MAX \
DEF:g="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:AVERAGE \
DEF:h="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:MAX \
CDEF:cdefca=TIME,1202925514,GT,a,a,UN,0,a,IF,IF,TIME,1202925514,GT,c,c,UN,0,c,IF,IF,TIME,1202925514,GT,e,e,UN,0,e,IF,IF,TIME,1202925514,GT,g,g,UN,0,g,IF,IF,+,+,+ \
LINE1:a#FFFF00FF:"1. Target Traffic In"  \
GPRINT:a:LAST:"      Current\:%8.2lf%s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:c#FFD660FF:"2. Target Traffic In"  \
GPRINT:c:LAST:"      Current\:%8.2lf%s"  \
GPRINT:c:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:d:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:e#CAF100FF:"1. Target Traffic Out"  \
GPRINT:e:LAST:"     Current\:%8.2lf%s"  \
GPRINT:e:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:f:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:g#CCBB00FF:"2. Target Traffic Out"  \
GPRINT:g:LAST:"     Current\:%8.2lf%s"  \
GPRINT:g:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:h:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:a#FF0000FF:"1. Target Again Traffic In"  \
GPRINT:a:LAST:"Current\:%8.2lf%s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:cdefca#000000FF:"AllDsNoDups"  \
GPRINT:cdefca:LAST:"               Current\:%8.2lf%s"  \
GPRINT:cdefca:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:cdefca:MAX:"Maximum\:%8.2lf%s\n"</PRE
><P
>The data sources are denoted by the letters <SPAN
CLASS="GUILABEL"
>a</SPAN
> to <SPAN
CLASS="GUILABEL"
>h</SPAN
>.
					<SPAN
CLASS="GUILABEL"
>cdefca</SPAN
> represents the important part. You surely notice, that
					all data sources using consolidation function AVERAGE are taken into account while MAX is skipped.
					Please pay attention to the data source denoted by <SPAN
CLASS="GUILABEL"
>a</SPAN
>. Even though the data source appears twice,
					the cdef shows it only once. This is due to the duplicate suppression.</P
></DIV
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN2932"
></A
><P
><B
>Example 19-2. Sum up all Data Sources Including Duplicates</B
></P
><P
>This is the list of graph items defined. Please note,
					that Item#17-20 are duplicates of Item#1-4. Even if it usually does not make sense, for this
					discussion it is very valuable. Item#21-24 are related to a
					<B
CLASS="EMPHASIS"
>cdef=ALL_DATA_SOURCES_DUPS</B
></P
><PRE
CLASS="SCREEN"
>Graph Item  Data Source                         Graph Item Type  CF Type
Item # 1    (traffic_in): 1. Target Traffic In 	          LINE1  AVERAGE
Item # 2    (traffic_in): Current:                       GPRINT     LAST
Item # 3    (traffic_in): Average:                       GPRINT  AVERAGE
Item # 4    (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 5    (traffic_in): 2. Target Traffic In            LINE1  AVERAGE
Item # 6    (traffic_in): Current:                       GPRINT     LAST
Item # 7    (traffic_in): Average:                       GPRINT  AVERAGE
Item # 8    (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 9    (traffic_out): 1. Target Traffic Out          LINE1  AVERAGE
Item # 10   (traffic_out): Current:                      GPRINT     LAST
Item # 11   (traffic_out): Average:                      GPRINT  AVERAGE
Item # 12   (traffic_out): Maximum:[HR]                  GPRINT      MAX
Item # 13   (traffic_out): 2. Target Traffic Out          LINE1  AVERAGE
Item # 14   (traffic_out): Current:                      GPRINT     LAST
Item # 15   (traffic_out): Average:                      GPRINT  AVERAGE
Item # 16   (traffic_out): Maximum:[HR]                  GPRINT      MAX
Item # 17   (traffic_in): 1. Target Again Traffic In      LINE1  AVERAGE
Item # 18   (traffic_in): Current:                       GPRINT     LAST
Item # 19   (traffic_in): Average:                       GPRINT  AVERAGE
Item # 20   (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 21   (No Task): AllDsDups                          LINE1  AVERAGE
Item # 22   (No Task): Current:                          GPRINT     LAST
Item # 23   (No Task): Average:                          GPRINT  AVERAGE
Item # 24   (No Task): Maximum:[HR]                      GPRINT      MAX</PRE
><P
>And this is the rrd graph statement:</P
><PRE
CLASS="SCREEN"
>/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Traffic AllDsDups" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:AVERAGE \
DEF:b="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:MAX \
DEF:c="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:AVERAGE \
DEF:d="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:MAX \
DEF:e="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:AVERAGE \
DEF:f="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:MAX \
DEF:g="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:AVERAGE \
DEF:h="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:MAX \
CDEF:cdefca=TIME,1202925583,GT,a,a,UN,0,a,IF,IF,TIME,1202925583,GT,c,c,UN,0,c,IF,IF,TIME,1202925583,GT,e,e,UN,0,e,IF,IF,TIME,1202925583,GT,g,g,UN,0,g,IF,IF,TIME,1202925583,GT,a,a,UN,0,a,IF,IF,+,+,+,+ \
LINE1:a#FFFF00FF:"1. Target Traffic In"  \
GPRINT:a:LAST:"      Current\:%8.2lf%s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:c#FFD660FF:"2. Target Traffic In"  \
GPRINT:c:LAST:"      Current\:%8.2lf%s"  \
GPRINT:c:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:d:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:e#CAF100FF:"1. Target Traffic Out"  \
GPRINT:e:LAST:"     Current\:%8.2lf%s"  \
GPRINT:e:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:f:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:g#CCBB00FF:"2. Target Traffic Out"  \
GPRINT:g:LAST:"     Current\:%8.2lf%s"  \
GPRINT:g:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:h:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:a#FF0000FF:"1. Target Again Traffic In"  \
GPRINT:a:LAST:"Current\:%8.2lf%s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:cdefca#000000FF:"AllDsDups"  \
GPRINT:cdefca:LAST:"                 Current\:%8.2lf%s"  \
GPRINT:cdefca:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:cdefca:MAX:"Maximum\:%8.2lf%s\n"</PRE
><P
>Again, the data sources are denoted by the letters <SPAN
CLASS="GUILABEL"
>a</SPAN
> to <SPAN
CLASS="GUILABEL"
>h</SPAN
> and
					<SPAN
CLASS="GUILABEL"
>cdefca</SPAN
> represents the important part. Please pay attention to the data source
					denoted by <SPAN
CLASS="GUILABEL"
>a</SPAN
> appearing twice in this cdef.
					This is, because it appears twice (Item#17-20) in the graph item list
					and duplicate suppression is not in effect.</P
></DIV
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN2944"
></A
><P
><B
>Example 19-3. Sum up Similar Data Sources Omitting Duplicates</B
></P
><P
>Everything is very much like the above; again
					Item#17-20 are duplicates of Item#1-4. Item#21-24 are related to a
					<B
CLASS="EMPHASIS"
>cdef=SIMILAR_DATA_SOURCES_NODUPS</B
> and are associated with the
					data source <B
CLASS="EMPHASIS"
>traffic_in</B
> of the 1. target (it does not matter, which target is chosen,
					as long as you only choose a traffic_in data source)</P
><PRE
CLASS="SCREEN"
>Graph Item  Data Source                         Graph Item Type  CF Type
Item # 1    (traffic_in): 1. Target Traffic In 	          LINE1  AVERAGE
Item # 2    (traffic_in): Current:                       GPRINT     LAST
Item # 3    (traffic_in): Average:                       GPRINT  AVERAGE
Item # 4    (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 5    (traffic_in): 2. Target Traffic In            LINE1  AVERAGE
Item # 6    (traffic_in): Current:                       GPRINT     LAST
Item # 7    (traffic_in): Average:                       GPRINT  AVERAGE
Item # 8    (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 9    (traffic_out): 1. Target Traffic Out          LINE1  AVERAGE
Item # 10   (traffic_out): Current:                      GPRINT     LAST
Item # 11   (traffic_out): Average:                      GPRINT  AVERAGE
Item # 12   (traffic_out): Maximum:[HR]                  GPRINT      MAX
Item # 13   (traffic_out): 2. Target Traffic Out          LINE1  AVERAGE
Item # 14   (traffic_out): Current:                      GPRINT     LAST
Item # 15   (traffic_out): Average:                      GPRINT  AVERAGE
Item # 16   (traffic_out): Maximum:[HR]                  GPRINT      MAX
Item # 17   (traffic_in): 1. Target Again Traffic In      LINE1  AVERAGE
Item # 18   (traffic_in): Current:                       GPRINT     LAST
Item # 19   (traffic_in): Average:                       GPRINT  AVERAGE
Item # 20   (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 21   (traffic_in): SimilarDsNoDups                 LINE1  AVERAGE
Item # 22   (traffic_in): Current:                       GPRINT     LAST
Item # 23   (traffic_in): Average:                       GPRINT  AVERAGE
Item # 24   (traffic_in): Maximum:[HR]                   GPRINT      MAX</PRE
><P
>And this is the rrd graph statement:</P
><PRE
CLASS="SCREEN"
>/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Traffic SimilarDsNoDups" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:AVERAGE \
DEF:b="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:MAX \
DEF:c="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:AVERAGE \
DEF:d="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:MAX \
DEF:e="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:AVERAGE \
DEF:f="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:MAX \
DEF:g="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:AVERAGE \
DEF:h="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:MAX \
CDEF:cdefca=TIME,1202924474,GT,a,a,UN,0,a,IF,IF,TIME,1202924474,GT,c,c,UN,0,c,IF,IF,+ \
CDEF:cdefcd=TIME,1202924474,GT,b,b,UN,0,b,IF,IF,TIME,1202924474,GT,d,d,UN,0,d,IF,IF,+ \
LINE1:a#FFFF00FF:"1. Target Traffic In"  \
GPRINT:a:LAST:"      Current\:%8.2lf%s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:c#FFD660FF:"2. Target Traffic In"  \
GPRINT:c:LAST:"      Current\:%8.2lf%s"  \
GPRINT:c:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:d:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:e#CAF100FF:"1. Target Traffic Out"  \
GPRINT:e:LAST:"     Current\:%8.2lf%s"  \
GPRINT:e:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:f:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:g#CCBB00FF:"2. Target Traffic Out"  \
GPRINT:g:LAST:"     Current\:%8.2lf%s"  \
GPRINT:g:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:h:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:a#FF0000FF:"1. Target Again Traffic In"  \
GPRINT:a:LAST:"Current\:%8.2lf%s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:cdefca#000000FF:"SimilarDsNoDups"  \
GPRINT:cdefca:LAST:"           Current\:%8.2lf%s"  \
GPRINT:cdefca:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:cdefcd:MAX:"Maximum\:%8.2lf%s\n" </PRE
><P
><SPAN
CLASS="GUILABEL"
>cdefca</SPAN
> calculates the SUM of all traffic_in data sources, but
					pays attention only to consolidation function AVERAGE. Duplicate suppression makes sure, that the second
					occurrence of the 1. target is not taken into account. So it's only summing data source
					<SPAN
CLASS="GUILABEL"
>a</SPAN
> and <SPAN
CLASS="GUILABEL"
>c</SPAN
>. <SPAN
CLASS="GUILABEL"
>cdefca</SPAN
> is used the the LINE1
					graph item with exact match for consolidation function AVERAGE as well as for the best matched
					consolidation functions LAST and MIN.</P
><P
><SPAN
CLASS="GUILABEL"
>cdefcd</SPAN
> calculates the SUM of all traffic_in data sources, but
					pays attention only to consolidation function MAX. Again, duplicate suppression is in effect.
					So it's only summing data source
					<SPAN
CLASS="GUILABEL"
>b</SPAN
> and <SPAN
CLASS="GUILABEL"
>d</SPAN
>. <SPAN
CLASS="GUILABEL"
>cdefcd</SPAN
> is used for the
					graph item with exact match for consolidation function MAX only. This is, because my rra settings
					only define AVERAGE and MAX, where LAST and MIN are omitted. This may differ for installations
					defining LAST and MIN as well.</P
></DIV
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN2962"
></A
><P
><B
>Example 19-4. Sum up Similar Data Sources Including Duplicates</B
></P
><P
>Again, please note,
					that Item#17-20 are duplicates of Item#1-4. Item#21-24 are related to a
					<B
CLASS="EMPHASIS"
>cdef=SIMILAR_DATA_SOURCES_DUPS</B
> and are associated with the
					data source <B
CLASS="EMPHASIS"
>traffic_in</B
> of the 1. target (it does not matter, which target is chosen,
					as long as you only choose a traffic_in data source)</P
><PRE
CLASS="SCREEN"
>Graph Item  Data Source                         Graph Item Type  CF Type
Item # 1    (traffic_in): 1. Target Traffic In 	          LINE1  AVERAGE
Item # 2    (traffic_in): Current:                       GPRINT     LAST
Item # 3    (traffic_in): Average:                       GPRINT  AVERAGE
Item # 4    (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 5    (traffic_in): 2. Target Traffic In            LINE1  AVERAGE
Item # 6    (traffic_in): Current:                       GPRINT     LAST
Item # 7    (traffic_in): Average:                       GPRINT  AVERAGE
Item # 8    (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 9    (traffic_out): 1. Target Traffic Out          LINE1  AVERAGE
Item # 10   (traffic_out): Current:                      GPRINT     LAST
Item # 11   (traffic_out): Average:                      GPRINT  AVERAGE
Item # 12   (traffic_out): Maximum:[HR]                  GPRINT      MAX
Item # 13   (traffic_out): 2. Target Traffic Out          LINE1  AVERAGE
Item # 14   (traffic_out): Current:                      GPRINT     LAST
Item # 15   (traffic_out): Average:                      GPRINT  AVERAGE
Item # 16   (traffic_out): Maximum:[HR]                  GPRINT      MAX
Item # 17   (traffic_in): 1. Target Again Traffic In      LINE1  AVERAGE
Item # 18   (traffic_in): Current:                       GPRINT     LAST
Item # 19   (traffic_in): Average:                       GPRINT  AVERAGE
Item # 20   (traffic_in): Maximum:[HR]                   GPRINT      MAX
Item # 21   (traffic_in): SimilarDsDups                   LINE1  AVERAGE
Item # 22   (traffic_in): Current:                       GPRINT     LAST
Item # 23   (traffic_in): Average:                       GPRINT  AVERAGE
Item # 24   (traffic_in): Maximum:[HR]                   GPRINT      MAX</PRE
><P
>And this is the rrd graph statement:</P
><PRE
CLASS="SCREEN"
>/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Traffic SimilarDsDups" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:AVERAGE \
DEF:b="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_in:MAX \
DEF:c="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:AVERAGE \
DEF:d="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_in:MAX \
DEF:e="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:AVERAGE \
DEF:f="/var/www/html/cacti/rra/target1_traffic_in_235.rrd":traffic_out:MAX \
DEF:g="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:AVERAGE \
DEF:h="/var/www/html/cacti/rra/target2_traffic_in_8.rrd":traffic_out:MAX \
CDEF:cdefca=TIME,1202925634,GT,a,a,UN,0,a,IF,IF,TIME,1202925634,GT,c,c,UN,0,c,IF,IF,TIME,1202925634,GT,a,a,UN,0,a,IF,IF,+,+ \
CDEF:cdefcd=TIME,1202925634,GT,b,b,UN,0,b,IF,IF,TIME,1202925634,GT,d,d,UN,0,d,IF,IF,TIME,1202925634,GT,b,b,UN,0,b,IF,IF,+,+ \
LINE1:a#FFFF00FF:"1. Target Traffic In"  \
GPRINT:a:LAST:"      Current\:%8.2lf%s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:c#FFD660FF:"2. Target Traffic In"  \
GPRINT:c:LAST:"      Current\:%8.2lf%s"  \
GPRINT:c:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:d:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:e#CAF100FF:"1. Target Traffic Out"  \
GPRINT:e:LAST:"     Current\:%8.2lf%s"  \
GPRINT:e:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:f:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:g#CCBB00FF:"2. Target Traffic Out"  \
GPRINT:g:LAST:"     Current\:%8.2lf%s"  \
GPRINT:g:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:h:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:a#FF0000FF:"1. Target Again Traffic In"  \
GPRINT:a:LAST:"Current\:%8.2lf%s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf%s\n"  \
LINE1:cdefca#000000FF:"SimilarDsDups"  \
GPRINT:cdefca:LAST:"             Current\:%8.2lf%s"  \
GPRINT:cdefca:AVERAGE:"Average\:%8.2lf%s"  \
GPRINT:cdefcd:MAX:"Maximum\:%8.2lf%s\n" </PRE
><P
><SPAN
CLASS="GUILABEL"
>cdefca</SPAN
> and <SPAN
CLASS="GUILABEL"
>cdefcd</SPAN
> represents the important part. You surely notice, that
					all data sources using consolidation function AVERAGE are taken into account for calculation <SPAN
CLASS="GUILABEL"
>cdefca</SPAN
>,
					while MAX is calculated with <SPAN
CLASS="GUILABEL"
>cdefcd</SPAN
>.
					Please pay attention to the data source denoted by <SPAN
CLASS="GUILABEL"
>a</SPAN
> and <SPAN
CLASS="GUILABEL"
>b</SPAN
>, respectively,
					appearing twice in those cdefs as expected.</P
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="CDEF_MORE_EXAMPLES"
>More CDEF Examples</A
></H2
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN2979"
></A
><P
><B
>Example 19-5. Disk Usage as a Percentage</B
></P
><P
>This example is based on the standard data template <B
CLASS="EMPHASIS"
>ucd/net - Hard Drive Space</B
>.
					Cacti ships an associated graph template named <B
CLASS="EMPHASIS"
>ucd/net - Available Disk Space</B
>.
					Often, users complain about the fact, tha tthis template prints free and used space as absolute figures only.
					But instead of knowing, that your data partition has about 10GB used space, you may be interested in the
					percentage used. So let's create a simple example to show the power of the recently introduced special data sources.</P
><P
>To make it work, we need two new CDEFs. The first one may come in useful for a bunch of
					different graph templates. It's named <B
CLASS="EMPHASIS"
>Make Current Data Source 0</B
>. On a first glance,
					you may wonder why this CDEF is needed. It is used for those data sources, that will be used
					for calculations but shall not show up themselves. Here's the definition</P
><PRE
CLASS="SCREEN"
>cdef=CURRENT_DATA_SOURCE,0,*</PRE
><P
>Now, the other one, named <B
CLASS="EMPHASIS"
>Current DS as Percentage of all DS</B
></P
><PRE
CLASS="SCREEN"
>cdef=CURRENT_DATA_SOURCE,ALL_DATA_SOURCES_NODUPS,/,100,*</PRE
><P
>Here's a short discussion. The first three elements read: Take the current data source and
					divide it by "The Sum of All Data Sources (Don't include Duplicates)". To form a percentage, you will have
					to multiply by 100. This is done by adding the elements four and five.</P
><P
>Now, let's build up the new graph</P
><PRE
CLASS="SCREEN"
>Graph Item   Data Source         Graph Item Type  CF Type  Item Color
    Item#1   (hdd_used):         LINE1            AVERAGE
    Item#2   (hdd_free):         LINE1            AVERAGE
    Item#3   (hdd_used): % Used  AREA             AVERAGE  FF0000</PRE
><P
>Item#1+2 in most cases will exceed the maximum percentage of 100 by magnitudes.
					So they are associated with the CDEF named <B
CLASS="EMPHASIS"
>Make Current Data Source 0</B
> to make them zero.
					This adds the data sources to the graph but avoids them showing up. The pseudo-color of "None" is associated to
					both of them.</P
><P
>Iten#3 is associated to the data source <B
CLASS="EMPHASIS"
>hdd_used</B
> as we want to print the
					"% Used" of the partition. The CDEF is <B
CLASS="EMPHASIS"
>Current DS as Percentage of all DS</B
>, the
					color is set to "red (FF0000)".</P
><P
>And this is the rrd graph statement:</P
><PRE
CLASS="SCREEN"
>/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="gandalf - Disk Space - / %used" \
--rigid \
--base=1024 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Percent" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/target1_hdd_free_236.rrd":hdd_used:AVERAGE \
DEF:b="/var/www/html/cacti/rra/target1_hdd_free_236.rrd":hdd_free:AVERAGE \
CDEF:cdefa=a,0,* \
CDEF:cdefb=b,0,* \
CDEF:cdefc=a,TIME,1203272123,GT,a,a,UN,0,a,IF,IF,TIME,1203272123,GT,b,b,UN,0,b,IF,IF,+,/,100,* \
LINE1:cdefa:""  \
LINE1:cdefb:""  \
AREA:cdefc#FF0000FF:"% Used"</PRE
><P
><SPAN
CLASS="GUILABEL"
>cdefa</SPAN
> and <SPAN
CLASS="GUILABEL"
>cdefb</SPAN
> are used to make the according graph
					items zero. <SPAN
CLASS="GUILABEL"
>cdefc</SPAN
> performs the percentage calculation.</P
><P
>You may of cource add GPRINT legends as usual. If you do this for the "% Used" entry only, you
					will get surprising results, if your rrd file holds either MAXIMUM, LAST and/or MINIMUM
					consolidation function(s). This is left as an exercise to you ;-)</P
></DIV
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN3005"
></A
><P
><B
>Example 19-6. Background Colors for Day and Night</B
></P
><P
>This set of CDEFs is used to colorize the background of a graph with different colors for day, night and weekends.
					The CDEFs are created as usual, we will show the CDEF definition only. Examples are taken from rrdtool-users mailing list
					courtesy Erik de Mare. Here are the definitions</P
><P
><B
CLASS="EMPHASIS"
>Background for Daytime</B
></P
><PRE
CLASS="SCREEN"
>cdef=LTIME,86400,%,28800,GT,LTIME,86400,%,64800,LT,INF,UNKN,CURRENT_DATA_SOURCE,*,IF,UNKN,CURRENT_DATA_SOURCE,*,IF</PRE
><P
><B
CLASS="EMPHASIS"
>Background for Nighttime</B
></P
><PRE
CLASS="SCREEN"
>cdef=LTIME,86400,%,28800,LT,INF,LTIME,86400,%,64800,GT,INF,UNKN,CURRENT_DATA_SOURCE,*,IF,IF</PRE
><P
><B
CLASS="EMPHASIS"
>Background for Weekend</B
></P
><PRE
CLASS="SCREEN"
>cdef=LTIME,604800,%,172800,GT,LTIME,604800,%,345600,LT,INF,UNKN,CURRENT_DATA_SOURCE,*,IF,UNKN,CURRENT_DATA_SOURCE,*,IF</PRE
><P
>The value of <B
CLASS="EMPHASIS"
>86400</B
> represents the number of seconds of a day, whereas
					<B
CLASS="EMPHASIS"
>28800</B
> represents 8:00, defined as the start of the day. End of the day, <B
CLASS="EMPHASIS"
>64800</B
> is
					assumed at 18:00. Please replace those values if required. For weekends, same logic applies.</P
><P
>Now, let's apply those new CDEFs to a Graph Template. For this example, I've chosen the <B
CLASS="EMPHASIS"
>Unix - Processes</B
>
					that applies to localhost only. In turn, please create three new graph items, associate the processes data source,
					make them AREAs, select	a color and opacity. Choose the daytime , nighttime and weekend CDEF in this sequence.
					As a last step, move those three new graph items to the top. I've chosen opacity of 20% for Item#1 to 3.</P
><PRE
CLASS="SCREEN"
>Graph Item  Data Source                Graph Item Type  CF Type  Item Color
Item # 1    (proc):                    AREA             AVERAGE  FFFF00
Item # 2    (proc):                    AREA             AVERAGE  0000FF
Item # 3    (proc):                    AREA             AVERAGE  2E3127
Item # 4    (proc): Running Processes  AREA             AVERAGE  F51D30
Item # 5    (proc): Current:           GPRINT           LAST
Item # 6    (proc): Average:           GPRINT           AVERAGE
Item # 7    (proc): Maximum:           GPRINT           MAX</PRE
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="rrdtool_features.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="scripts.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>RRDTool Specific Features</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="rrdtool_features.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Command Line Scripts</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>